<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="../ucs.css">
    <link rel="stylesheet" href="../font/iconfont.css">
    <link rel="stylesheet" href="../demo.css">
</head>
<body>
    <div id="main"></div>
    <script type="text/javascript" src="../../dist/libs/u-eventhub.js"></script>
    <script type="text/javascript" src="../../dist/libs/engine.js"></script>
    <script type="text/javascript" src="../../dist/ucsmy-ui.js"></script>

    <script type="text/javascript">
        //个人实名信息
        var realNameInfoDM = new UDM({
            value:{
                AccType:0,
                Mobile:"",
                IsBindMobile:"",//是否绑定手机
                BindMobileUrl:"../demoUserInfo/index.html",//绑定手机链接
                IsBindIDCard:"",//是否验证身份
                BindIDCardUrl:"../demoUserInfo/index.html",//验证身份链接
                IsBindBankCard:"",//是否绑卡
                BindBankCardUrl:"../demoMyBankCard/index.html",//绑卡链接
                Current:"MyBankCard",  //当前选中菜单
                InvestAccountUrl:"../demoMyAccount11/index.html",//投资账户总览链接
                InvestListUrl:"../demoMyInvest/index.html",//投资记录链接
                MyBankCardUrl:"../demoMyBankCard/index.html",//我的银行卡链接
                InvestInfoUrl:"../demoUserInfo/index.html",//投资个人信息
                InvestMessageUrl:"../demoUserMessageCenter/index.html",//投资消息中心
                FinanceAccountUrl:"../demoFinanceAccount/index.html",//融资账户总览链接
                FinanceListUrl:"../demoFinanceList/index.html",//融资记录链接
                FinanceAccountInfoUrl:"../demoAccountInfo/index.html",//融资账号信息
                FinanceMessageUrl:"../demoCompanyMessageCenter/index.html"//融资消息中心
            }
        })


        /* 以下是添加账户弹窗中表单的数据模型 */
        //开户姓名
        var acNameDM = new UDM({
            placeholder:"请输入您的开户姓名",
            validator:[
                {type:"require",msg:"请输入您的开户姓名"}
            ]
        });
        //身份证号
        var acIdNumDM = new UDM({
            placeholder:"请输入您的身份证号码",
            validator:[
                {type:"require",msg:"请输入您的身份证号码"}
            ]
        });
        //开户行
        var acBankOptionDM = new UDM({
            value:{
                BankId:"",
                options:[
                    {
                        option: "浙商银行",
                        value: "316"
                    },
                    {
                        option: "中国工商银行",
                        value: "102"
                    },
                    {
                        option: "中国农业银行",
                        value: "103"
                    },
                    {
                        option: "中国银行",
                        value: "104"
                    }
                ]
            },
            selected:'请选择开户银行',
            validator:[{type:'fn',fn:function () {
                if(!acBankOptionDM.value.BankId){
                    return false;
                }else {
                    return true;
                }
            }}],
            onChange: function (v) {
                console.log(v)
                acBankOptionDM.setValue({BankId:v.value});
                //执行ajax请求
                acBankOptionDM.validate();
                console.log(acBankOptionDM.value.BankId);
            }
        });
        //银行账号
        var acBankNumDM = new UDM({
            placeholder:"仅限银行储蓄卡",
            validator:[
                {type:"require",msg:"银行账号不能为空"}
            ]
        });
        //确认银行账户
        var acBankNum2DM = new UDM({
            placeholder:"请再次输入银行账号",
            validator:[
                {type:"require",msg:"银行账号不能为空"},
                {
                    type:"fn",
                    fn:function(v){
                        if(v == acBankNumDM.getValue()){
                            return true;
                        }else{
                            return false;
                        }
                    },
                    msg:"两次账号输入不一致"
                }
            ]
        });
        //预留手机号码
        var acPhoneDM = new UDM({
            placeholder:"请输入预留手机号码",
            validator:[
                {type:"require",msg:"手机号码不能为空"},
                {type:"mobile"}
            ]
        });
        //图形验证码
        var acImgCodeDM = new UDM({
            placeholder:"请输入图形验证码",
            validator:[
                {type:"require",msg:"图形验证码不能为空"}
            ]
        });
        //图形验证码按钮
        var acImgBtnDM = new UDM({
            value:"../images/code.jpg",
            onClick:function(){
                acImgBtnDM.setValue("../images/logoe.jpg");
            }
        });
        //短信验证码
        var acMsgCodeDM = new UDM({
            placeholder:"请输入短信验证码",
            validator:[
                {type:"require",msg:"短信验证码不能为空"}
            ]
        });
        //获取验证码按钮
        var acMsgBtnDM = new UDM({
            count:3,
            onClick:function(){
                console.log('dddd')
              var phoneMsg = acPhoneDM.validate(),
                imgMsg = acImgCodeDM.validate();
                UEventHub.emit('getcode',acMsgBtnDM);
//                if(!phoneMsg && !imgMsg){
//					$.ajax({
                    /* code hear */
//						success:function(){
//                    var _msg = "手机号已注册";

//                    phoneDM.setError(_msg);
//						}
//					});
//					phoneDM.validate();
//					console.log(phoneDM.validate());

//                }else{
//                    return false;
//                }
            }
        });
        //复选框
        var checkVal = true;
        var acCheckboxDM = new UDM({
            value:checkVal,
            onClick:function(v){
                acCheckboxDM.setValue(v);
                console.log(acCheckboxDM.value);
            }
        });
        /* 添加账户END */
        //链接
        var URLDM = new UDM({
            agreement:"协议链接"    //协议链接
        });
        //添加银行卡模型
        var aclayerDM = new UDM({
        	confirmBack:function () {
//        	    ULoadingDialog.show();
                UDialog.alert({title:'dddd',content:"jadjfladfl"});
                setTimeout(function () {
//                    ULoadingDialog.hide();

//                    window.location.href = "../demoMyBankCard/index.html"
                },2000)
            }
        })

        var ajaxFn = function () {

            /*个人实名信息*/
            var realName = {
                AccType:0,
                Mobile:"155****2132",
                IsBindMobile:true,//是否绑定手机
                BindMobileUrl:"../demoUserInfo/index.html",//绑定手机链接
                IsBindIDCard:false,//是否验证身份
                BindIDCardUrl:"../demoUserInfo/index.html",//验证身份链接
                IsBindBankCard:false,//是否绑卡
                BindBankCardUrl:"../demoMyBankCard/index.html",//绑卡链接
                Current:"MyBankCard",  //当前选中菜单
                InvestAccountUrl:"../demoMyAccount/index.html",//投资账户总览链接
                InvestListUrl:"../demoMyInvest/index.html",//投资记录链接
                MyBankCardUrl:"../demoMyBankCard/index.html",//我的银行卡链接
                InvestInfoUrl:"../demoUserInfo/index.html",//投资个人信息
                InvestMessageUrl:"../demoUserMessageCenter/index.html",//投资消息中心
                FinanceAccountUrl:"../demoFinanceAccount/index.html",//融资账户总览链接
                FinanceListUrl:"../demoFinanceList/index.html",//融资记录链接
                FinanceAccountInfoUrl:"../demoAccountInfo/index.html",//融资账号信息
                FinanceMessageUrl:"../demoCompanyMessageCenter/index.html"//融资消息中心
            };

            realNameInfoDM.setValue(realName);
        }
        var PageDM = {
            realNameInfo: realNameInfoDM,
            acName: acNameDM,
            acIdNum: acIdNumDM,
            acBankOption: acBankOptionDM,
            acBankNum: acBankNumDM,
            acBankNum2: acBankNum2DM,
            acPhone: acPhoneDM,
            acImgCode: acImgCodeDM,
            acImgBtn: acImgBtnDM,
            acMsgCode: acMsgCodeDM,
            acMsgBtn: acMsgBtnDM,
            acCheckbox: acCheckboxDM,
            aclayer: aclayerDM,
            url:URLDM
        }

        UEventHub.on('pageLoad', function(v){
            ajaxFn();
            console.log(v);
            UEventHub.emit("test","你好，","世界！");
        });
    </script>
<script type="text/javascript" src="../demoAddBankCard\index.js"></script></body>
</html>